from django.contrib import admin
from .models import Student, StudentDetail
# Register your models here.


class StudentAdmin(admin.ModelAdmin):

    list_display = ['id', 'name', 'age', 'sex', 'mobile', 'qq', 'webchat'] # 页面的展示字段
    list_display_links = ['name', 'sex'] # 默认id，可设置多个，链接可以跳转
    list_filter = ['sex'] # 过滤器，可多个（and关系）。
    search_fields = ['qq', 'webchat'] # 搜索
    list_per_page = 3 # 每页显示的数量

    # fields = ['name', 'age'] # 详情页显示的字段
    fieldsets = [ # 分组显示
        (None, {'fields': ['name', 'age']}),
        ('联系信息', {'fields': ['qq', 'mobile', 'webchat']}),
        ('设置', {'fields': ['is_delete']}),
    ]

admin.site.register(Student, StudentAdmin) # 模型注册
admin.site.register(StudentDetail)